package com.my;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.EventPullSource;

public class HelloWorldPlushlet implements Serializable {
	private static final long serialVersionUID = 1L;

	static public class HelloWorldEvent extends EventPullSource {
		@Override
		protected long getSleepTime() {
			return 3000; // 刷新时间
		}

		@Override
		protected Event pullEvent() {
			Event event = Event.createDataEvent("/source/event");// 事件标识
			String s = "这是中文";
			s = toISO88591(s);
			//String s = "fuck";
			event.setField("msg", s);// 封装参数
			return event;
			//event.setField("msg", "hello");
			//return event;
		}
	}

	public static String toISO88591(String str) {
		try {
			str = new String(str.getBytes("UTF-8"), "ISO-8859-1");
		} catch (UnsupportedEncodingException ex) {
			ex.printStackTrace();
		}
		return str;
	}

}